home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / bbs / fido10as.zip / FIDOTEST.CPP < prev    next >
C/C++ Source or Header  |  1997-04-08  |  3KB  |  98 lines

  1. /*
  2.  * FidoNet(tm) Address Parsing Class (full support for 5D format)
  3.  *
  4.  * Copyright (c) 1995, 1997 by Branislav L. Slantchev
  5.  * A fine product of Silicon Creations, Inc. (gargoyle)
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the License which accompanies this
  9.  * software. This library is distributed in the hope that it will
  10.  * be useful, but without any warranty; without even the implied
  11.  * warranty of merchantability or fitness for a particular purpose.
  12.  *
  13.  * You should have received a copy of the License along with this
  14.  * library, in the file LICENSE.DOC; if not, write to the address
  15.  * below to receive a copy via electronic mail.
  16.  *
  17.  * You can reach Branislav L. Slantchev (Silicon Creations, Inc.)
  18.  * at bslantch@cs.angelo.edu. The file SUPPORT.DOC has the current
  19.  * telephone numbers and the postal address for contacts.
  20. */
  21. #include "fidoaddr.h"
  22. #include <iostream.h>
  23.  
  24. ostream&
  25. operator<<(ostream &os, const fido_address &fido)
  26. {
  27.     char buf[512];
  28.  
  29.     os << fido.merge5d(buf);
  30.     return os;
  31. }
  32.  
  33. void
  34. main()
  35. {
  36.     char buf[512];
  37.  
  38.     // several different constructors
  39.     fido_address a1;
  40.     fido_address a2(1, 383, 47, 2);
  41.     fido_address a3(1, 383, 47, 2, "fidonet.org");
  42.     fido_address a4(a3);
  43.     fido_address a5("1:383/47.2@fidonet.org");
  44.  
  45.     // check all constructors
  46.     cout << "expected                  result" << endl;
  47.     cout << "0:0/0.0                   " << a1 << endl;
  48.     cout << "1:383/47.2                " << a2 << endl;
  49.     cout << "1:383/47.2@fidonet.org    " << a3 << endl;
  50.     cout << "1:383/47.2@fidonet.org    " << a4 << endl;
  51.     cout << "1:383/47.2@fidonet.org    " << a5 << endl;
  52.  
  53.     // assignment operator
  54.     a1 = a2;
  55.     cout << "1:383/47.2                " << a1 << endl;
  56.     a1 = a1;
  57.     cout << "1:383/47.2                " << a1 << endl;
  58.     a1 = a5;
  59.     cout << "1:383/47.2@fidonet.org    " << a1 << endl;
  60.  
  61.     // different merging, with a full 5D address
  62.     cout << "1:383/47.2@fidonet.org    " << a1.merge(buf) << endl;
  63.     cout << "383/47                    " << a1.merge2d(buf) << endl;
  64.     cout << "1:383/47                  " << a1.merge3d(buf) << endl;
  65.     cout << "1:383/47.2                " << a1.merge4d(buf) << endl;
  66.  
  67.     // different address parsing
  68.     a1.split("1:383/47.2@fidonet.org");
  69.     cout << "1:383/47.2@fidonet.org    " << a1 << endl;
  70.  
  71.     a1.split("1:383/47@fidonet.org");
  72.     cout << "1:383/47.0@fidonet.org    " << a1 << endl;
  73.  
  74.     a1.split("383/47.2@fidonet.org");
  75.     cout << "0:383/47.2@fidonet.org    " << a1 << endl;
  76.  
  77.     a1.split("383/47@fidonet.org");
  78.     cout << "0:383/47.0@fidonet.org    " << a1 << endl;
  79.  
  80.     a1.split("1:383/47.2");
  81.     cout << "1:383/47.2                " << a1 << endl;
  82.  
  83.     a1.split("1:383/47");
  84.     cout << "1:383/47.0                " << a1 << endl;
  85.  
  86.     a1.split("383/47.2");
  87.     cout << "0:383/47.2                " << a1 << endl;
  88.  
  89.     a1.split("383/47");
  90.     cout << "0:383/47.0                " << a1 << endl;
  91.  
  92.     a1.split("47.2");
  93.     cout << "0:0/47.2                  " << a1 << endl;
  94.  
  95.     a1.split("47");
  96.     cout << "0:0/47.0                  " << a1 << endl;
  97. }
  98.